/*
 * xputil.h
 *
 *  Created on: 2010-05-29
 *      Author: lxb
 */

#ifndef _XPUTIL_H_INCLUDED_
#define _XPUTIL_H_INCLUDED_

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
 * <Includes>
 *****************************************************************************/

/******************************************************************************
 * <Defines>
 *****************************************************************************/
#define XPCHARSTACK_SIZE 128
#define XPPTRSTACK_SIZE 128
/******************************************************************************
 * <Enums>
 *****************************************************************************/

/******************************************************************************
 * <Typedefs>
 *****************************************************************************/
typedef struct xpcharstack xpcharstack;
struct xpcharstack
{
    unsigned char *buffer;
    unsigned int bufferSize;
    unsigned int ref;
};


typedef struct xpptrstack xpptrstack;
struct xpptrstack
{
    void **ptrbuffer;
    unsigned int bufsize;
    unsigned int ref;
};
/******************************************************************************
 * <API declarations>
 *****************************************************************************/

xpcharstack* xpcharstack_create();
xpcharstack* xpcharstack_createx(unsigned int initalSize);
void xpcharstack_delete(xpcharstack *stk);
void xpcharstack_push(xpcharstack *stk, unsigned char ch);
void xpcharstack_clear(xpcharstack *stk);
unsigned char xpcharstack_pop(xpcharstack *stk);
unsigned char* xpcharstack_getchars(xpcharstack *stk);
unsigned int xpcharstack_getsize(xpcharstack *stk);

xpptrstack* xpptrstack_create();
xpptrstack* xpptrstack_createx(unsigned int initialSize);
void xpptrstack_delete(xpptrstack *stk);
void xpptrstack_push(xpptrstack *stk, void *ptr);
void* xpptrstack_pop(xpptrstack *stk);
void* xpptrstack_gettop(xpptrstack *stk);
void xpptrstack_clear(xpptrstack *stk);

#ifdef __cplusplus
}
#endif

#endif /* _XPUTIL_H_INCLUDED_ */








